package demo4;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:处理异常
 * User: liangyuanzhang
 * Date: 2025-3-09
 * Time: 20:52
 */
public class Test {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {// 优化后不需要去close()
            int a = scanner.nextInt();
            System.out.println(a / 0);
        } catch (ArithmeticException e) {
            e.printStackTrace();
            System.out.println("处理(捕获)异常...");
        } finally {
            System.out.println("finally执行了...");
        }
    }
}
